package com.qrgenerator.src;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;

public class QRCodeGenerator {

	public static void createQRCodeImage(String fileName, String content){
        ByteArrayOutputStream out = QRCode.from(content)
                                        .to(ImageType.PNG).stream();
 
        try {
            FileOutputStream fout = new FileOutputStream(new File(
            		fileName));
 
            fout.write(out.toByteArray());
 
            fout.flush();
            fout.close();
            
 
        } catch (FileNotFoundException e) {
        	System.out.println("FileNotFoundException " + e.getMessage());
            // Do Logging
        } catch (IOException e) {
        	System.out.println("IOException " + e.getMessage());
            // Do Logging
        }
	}
}
